#include <iostream>
using namespace std;
int main()
{
    long long a1,a2,a3,b1,b2,b3;
    int n,i;
    cin>>n;
    for (i=0;i<n;i++)
    {
        cin>>a1>>a2>>a3>>b1>>b2>>b3;
        a1+=b1;
        a2+=b2;
        a3+=b3;
        if (a3>=60){a2+=a3/60;a3%=60;}
        if (a2>=60){a1+=a2/60;a2%=60;}
        cout<<a1<<' '<<a2<<' '<<a3<<endl;
    }
    return 0;
}
